/*
 * 易族智汇（北京）科技有限公司 版权所有。
 * 未经许可，您不得使用此文件。
 * 官方地址：www.javamall.com.cn
 */
package com.enation.app.javashop.core.client.fallback.promotion;

import com.enation.app.javashop.core.client.feignimpl.promotion.ExchangeGoodsClientFeignImpl;
import com.enation.app.javashop.core.handler.BaseFallbackFactory;
import com.enation.app.javashop.model.goods.dto.ExchangeClientDTO;
import com.enation.app.javashop.model.promotion.exchange.dos.ExchangeDO;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author fk
 * @version v2.0
 * @Description: 积分兑换断路器
 * @date 2018/9/27 14:38
 * @since v7.0.0
 */
@Component
public class ExchangeGoodsClientFallbackFactory extends BaseFallbackFactory<ExchangeGoodsClientFeignImpl> implements FallbackFactory {


    @Override
    protected ExchangeGoodsClientFeignImpl fallback() {
        return new ExchangeGoodsClientFallback();
    }

    /**
     * @author fk
     * @version v2.0
     * @Description: 积分兑换断路器
     * @date 2018/9/27 14:38
     * @since v7.0.0
     */
    @Component
    public static class ExchangeGoodsClientFallback implements ExchangeGoodsClientFeignImpl {

        protected final Log logger = LogFactory.getLog(this.getClass());

        @Override
        public ExchangeDO add(ExchangeClientDTO dto) {

            this.logger.error("交易服务异常，添加积分商品异常");

            return null;
        }

        @Override
        public ExchangeDO edit(ExchangeClientDTO dto) {

            this.logger.error("交易服务异常，修改积分商品异常");

            return null;
        }

        @Override
        public ExchangeDO getModelByGoods(Long goodsId) {

            this.logger.error("交易服务异常，获取某商品的积分换购信息异常");

            return null;
        }

        @Override
        public void del(Long goodsId) {
            if (logger.isErrorEnabled()) {
                logger.error("删除商品ID为" + goodsId + "的积分兑换信息发生错误");
            }
        }
    }
}
